﻿SET QUOTED_IDENTIFIER ON
GO
SET ARITHABORT ON
GO
SET NUMERIC_ROUNDABORT OFF
GO
SET CONCAT_NULL_YIELDS_NULL ON
GO
SET ANSI_NULLS ON
GO
SET ANSI_PADDING ON
GO
SET ANSI_WARNINGS ON
GO
ALTER TABLE dbo.bht_Columns ADD
	Sort int NULL
GO

ALTER PROCEDURE [dbo].[bhp_NemoGroupColumnsGet]
	@GroupId				INT
AS
BEGIN
	
	
	SELECT 
		id as ColumnId,
		name as ColumnName,
		ct.EnumType as ColumnType,
		ISNULL(t.rel, 0) as RelatedGroupId,
		ISNULL(c.DisplayName, name) as DisplayName,
		ISNULL(c.FormattingValue, '{0}') as FormattingValue,
		ISNULL(c.Sort, 0) as ColumnSort,
		c.RegexValidation,
		c.[Description],
		ISNULL(c.HideForEdition, 0) as HideForEdition,
		c.CustomEditControl
	FROM
		n_Tree t
		INNER JOIN bht_ColumnTypes ct ON t.typ = ct.ColumnType
		LEFT JOIN bht_Columns c ON t.id = c.ColumnId
	WHERE
		parent = @GroupId
		AND (t.del IS NULL OR t.del = 0)

END

